
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>运营平台</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.5 -->
  <link rel="stylesheet" href="/customer_plat/public/bootstrap/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="/customer_plat/public/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="/customer_plat/public/css/ionicons.min.css">
 
  <!--date-->
   <link rel="stylesheet" href="/customer_plat/public/datepicker/bootstrap-datepicker.min.css">
  
  <!-- Theme style -->
  <link rel="stylesheet" href="/customer_plat/public/dist/css/AdminLTE.min.css">
  <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="/customer_plat/public/dist/css/skins/_all-skins.min.css">
  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  
  <!--plugins-->
  <link rel="stylesheet" href="/customer_plat/public/plugins/datatables/dataTables.bootstrap.css">
  <!--[if lt IE 9]>
  <script src="/customer_plat/public/javascripts/html5shiv.min.js"></script>
  <script src="/customer_plat/public/javascripts/respond.min.js"></script>
  <![endif]-->
<script src="/customer_plat/public/plugins/jQuery/jquery-1.12.0.min.js"></script>
<script src="/customer_plat/public/layer/layer.js"></script>
<!-- Bootstrap 3.3.5 -->
<script src="/customer_plat/public/bootstrap/js/bootstrap.min.js"></script>
<script src="/customer_plat/public/bootstrap/js/bootstrap3-validation.js"></script>
<!--cityselect  -->
<script src="/customer_plat/public/javascripts/city/jquery.cityselect.js"></script>
<!-- AdminLTE App -->
<script src="/customer_plat/public/dist/js/app.js"></script>
<script src="/customer_plat/public/plugins/json2.js"></script>
<!--plugins-->
<script src="/customer_plat/public/plugins/datatables/jquery.dataTables.js"></script>
<script src="/customer_plat/public/plugins/datatables/dataTables.bootstrap.min.js"></script>

<script src="/customer_plat/public/plugins/jQueryUI/jquery-ui.js"></script>
<link rel="stylesheet" href="/customer_plat/public/plugins/jQueryUI/jquery-ui.css">
<script src="/customer_plat/public/datepicker/bootstrap-datepicker.min.js"></script>
<script src="/customer_plat/public/datepicker/bootstrap-datepicker.zh-CN.min.js"></script>
<!-- SlimScroll -->
<script src="/customer_plat/public/plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="/customer_plat/public/plugins/fastclick/fastclick.js"></script>
<script src="/customer_plat/public/select2/select2.min.js"></script>
<link rel="stylesheet" href="/customer_plat/public/select2/select2.min.css">
</head>
<body>
	<section class="content-header">
		<h1>
			供应商管理<small></small>
		</h1>
	</section>
	<section class="content">
		<div class="row">
			<div class="col-md-6">
				<!-- Horizontal Form -->
				<div class="box">
					<div class="box-header with-border">
						<h3 class="box-title">添加供应商</h3>
					</div>
					<!-- /.box-header -->
					<!-- form start -->
					<form class="form-horizontal" id="add_supplier_form">
						<div class="box-body">
							<div class="form-group">
								<label for="short_name" class="col-sm-2 control-label">供应简称</label>
								<div class="col-sm-7">
									<input type="text" class="form-control" id="shortName"
										check-type="required" required-message="请填写简称"
										placeholder="">
								</div>
							</div>
							<div class="form-group">
								<label for="long_name" class="col-sm-2 control-label">供应商名称</label>

								<div class="col-sm-7">
									<input type="text" class="form-control" id="longName"
										check-type="required" required-message="请填写名称"
										>
								</div>
							</div>


							<div class="form-group">
								<label for="english_name" class="col-sm-2 control-label">英文名称</label>
								<div class="col-sm-7">
									<input type="text" class="form-control" id="englishName"
										check-type="required" required-message="请填写英文名称"
										placeholder="">
								</div>
							</div>


							<div class="form-group">
								<label for="legal_person" class="col-sm-2 control-label">企业法人</label>
								<div class="col-sm-7">
									<input type="text" class="form-control" id="legalPerson"
										check-type="required" required-message="请填写企业法人"
										placeholder="">
								</div>
							</div>

							<div class="form-group">
								<label for="enterprise_code" class="col-sm-2 control-label">企业代码</label>
								<div class="col-sm-7">
									<input type="text" class="form-control" id="enterpriseCode"
										check-type="required" required-message="请填写企业代码"
										placeholder="">
								</div>
							</div>


							<div class="form-group">
								<label for="contactor" class="col-sm-2 control-label">联系人</label>
								<div class="col-sm-7">
									<input type="text" class="form-control" id="contactor"
										check-type="required" required-message="请填写联系人"
										placeholder="">
								</div>
							</div>

							<div class="form-group">
								<label for="telephone" class="col-sm-2 control-label">座机</label>
								<div class="col-sm-7">
									<input type="text" class="form-control" id="telephone"
										check-type="required telephone" required-message="请填写座机号码"
										placeholder="">
								</div>
							</div>

							<div class="form-group">
								<label for="mobile" class="col-sm-2 control-label">手机</label>
								<div class="col-sm-7">
									<input type="text" class="form-control" id="mobile"
										check-type="required mobile" required-message="请填写手机号码"
										placeholder="">
								</div>
							</div>

							<div class="form-group">
								<label for="postcode" class="col-sm-2 control-label">邮编</label>
								<div class="col-sm-7">
									<input type="text" class="form-control" id="postcode"
										check-type="required" required-message="请填客户邮编"
										placeholder="">
								</div>
							</div>
							<div class="form-group">
								<label for="fax" class="col-sm-2 control-label">传真号码</label>
								<div class="col-sm-7">
									<input type="text" class="form-control" id="fax"
										check-type="required telephone" required-message="请填写传真号码"
										placeholder="">
								</div>
							</div>
							<div class="form-group">
								<label for="email" class="col-sm-2 control-label">邮箱</label>
								<div class="col-sm-7">
									<input type="text" class="form-control" id="email"
										check-type="required mail" required-message="请填写邮箱"
										placeholder="">
								</div>
							</div>


							<div class="form-group">
								<label for="website" class="col-sm-2 control-label">网扯</label>
								<div class="col-sm-7">
									<input type="text" class="form-control" id="website"
										placeholder="">
								</div>
							</div>

							<div class="form-group" id="city_div">
								<label for="inputPassword3" class="col-sm-2 control-label">地区</label>
								<div class="col-sm-7">
									<div class="row">
										<div class="col-xs-3">
											<select class="form-control prov" id="province"
												></select>
										</div>
										<div class="col-xs-3">
											<select class="form-control city" disabled="disabled"
												id="city"></select>
										</div>
										<div class="col-xs-4">
											<select class="form-control dist" disabled="disabled"
												id="district"></select>
										</div>
										<div></div>
									</div>
								</div>
							</div>

							<div class="form-group">
								<label for="address" class="col-sm-2 control-label">地址</label>
								<div class="col-sm-7">
									<input type="text" class="form-control" id="address"
										check-type="required" required-message="请填写地址"
										placeholder="">
								</div>
							</div>

							<div class="form-group">
								<label for="memo" class="col-sm-2 control-label">备注</label>
								<div class="col-sm-7">
									<textarea class="form-control" id="memo" name="memo"
										placeholder=""></textarea>
								</div>
							</div>

						</div>

						<!-- /.box-body -->
						<div class="box-footer">
							<button type="button"  id="btn_add" class="btn btn-primary pull-right"
								onclick="add_supplier()">提交</button>
						</div>
						<!-- /.box-footer -->
					</form>
				</div>
			</div>
		</div>
	</section>

	<script>
		$(document).ready(function(){
			$("#city_div").citySelect({
				prov : "广东",
				city : "深圳"
			});
			 $("#add_supplier_form").validation();	
		});
		
		function add_supplier() {
			$("#btn_add").attr("disabled","true");
			if ($("#add_supplier_form").valid(this)==false){
			        return
			    }else{
			var shortName = $("#shortName").val();
			var longName = $("#longName").val();
			var englishName = $("#englishName").val();
			var legalPerson = $("#legalPerson").val();
			var enterpriseCode = $("#enterpriseCode").val();
			var contactor = $("#contactor").val();
			var mobile = $("#mobile").val();
			var telephone = $("#telephone").val();
			var postcode = $("#postcode").val();
			var fax = $("#fax").val();
			var email = $("#email").val();
			var website = $("#website").val();
			var province = $("#province").val();
			var city = $("#city").val();
			var district = $("#district").val();
			var address = $("#address").val();
			var memo = $("#memo").val();
			var p_data = {
				"shortName" : shortName,
				"longName" : longName,
				"englishName" : englishName,
				"enterpriseCode" : enterpriseCode,
				"legalPerson":legalPerson,
				"contactor" : contactor,
				"mobile" : mobile,
				"telephone" : telephone,
				"postcode" : postcode,
				"fax" : fax,
				"email" : email,
				"website" : website,
				"province" : province,
				"city" : city,
				"district" : district,
				"address" : address,
				"memo" : memo
			}
			$.ajax({
				type : "POST",
				url : "@{supplier.SupplierManageAction.addSupplierDo}",
				data : p_data,
				success : function(msg) {
					if (msg.status == '201') {
						supplier_clear();
						var str = "供应商" + shortName + "'增加成功";
					 	alert(str);
						$("#btn_add").attr("disabled","false");
					}else{
						alert("增加失败,错误信息 :"+msg.msg);
						$("#btn_add").attr("disabled","false");
					}
				}
			});
		}
	}

	function supplier_clear(){
		$("#add_supplier_form").validation();
		 $("#shortName").val();
		 $("#longName").val("");
		 $("#englishName").val("");
		 $("#legalPerson").val("");
	     $("#enterpriseCode").val("");
		 $("#contactor").val("");
		 $("#mobile").val("");
		 $("#telephone").val("");
		 $("#postcode").val("");
		 $("#fax").val("");
		 $("#email").val("");
		 $("#website").val("");
		 $("#province").val("广东");
		 $("#city").val("深圳");
		 $("#district").val("罗湖区");
		 $("#address").val("");
		 $("#memo").val("");
	}
	</script>
</body>